package com.example.bms.order.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.bms.order.dao.OrderDao;
import com.example.bms.order.entity.OrderEntity;
import com.example.bms.order.service.OrderService;
import org.springframework.util.ObjectUtils;


@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderDao, OrderEntity> implements OrderService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<OrderEntity> queryWrapper=new QueryWrapper<OrderEntity>();
        String name =(String) params.get("key");

        if(!ObjectUtils.isEmpty(name)){
            queryWrapper.like("oid",name).
                    or().like("status",name);;
        }
        queryWrapper.orderByDesc("status");
        queryWrapper.orderByAsc("time");

        IPage<OrderEntity> page = this.page(
                new Query<OrderEntity>().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }

}